#include "ota_api.h"
#include "flash_api.h"
#include "flash_board.h"

uint32_t GetTotalBootloaderFirmwareFileSize(void)
{
  return FlashGetBootloaderFirmwareMaxFileSize();
}

void EraseBootloaderFirmware(void)
{
  FlashDeleteBootloaderFirmwareFile();
}

void ReadBootloaderFirmwareData(uint32_t ReadAddress, void *pDataOut, uint32_t SizeOut)
{
  FlashReadBootloaderFirmwareFile(ReadAddress, pDataOut, SizeOut);
}

bool WriteBootloaderFirmwareData(uint32_t WriteAddress, const void *pDataIn, uint32_t SizeIn)
{
  return FlashWriteBootloaderFirmwareFile(WriteAddress, pDataIn, SizeIn);
}

uint32_t GetTotalApplicationFirmwareFileSize(void)
{
  return FlashGetApplictionFirmwareFileMaxSize();
}

void EraseApplicationFirmware(void)
{
  FlashDeleteApplictionFirmwareFile();
}

void ReadApplicationFirmwareData(uint32_t ReadAddress, void *pDataOut, uint32_t SizeOut)
{
  FlashReadApplictionFirmwareFile(ReadAddress, pDataOut, SizeOut);
}

bool WriteApplicationFirmwareData(uint32_t WriteAddress, const void *pDataIn, uint32_t SizeIn)
{
  return FlashWriteApplicationFirmwareFile(WriteAddress, pDataIn, SizeIn);
}

uint32_t GetTotalBackupBootloaderFirmwareFileSize(void)
{
  return FlashGetBackupBootloaderFirmwareFileSize();
}

void EraseBackupBootloaderFirmware(void)
{
  FlashDeleteBackupBootloaderFirmwareFile();
}

void ReadBackupBootloaderFirmwareData(uint32_t ReadAddress, void *pDataOut, uint32_t SizeOut)
{
  FlashReadBackupBootloaderFirmwareFile(ReadAddress, pDataOut, SizeOut);
}

bool WriteBackupBootloaderFirmwareData(uint32_t WriteAddress, const void *pDataIn, uint32_t SizeIn)
{
  return FlashWriteBackupBootloaderFirmwareFile(WriteAddress, pDataIn, SizeIn);
}

uint32_t GetBackupBootloaderFirmwareCheckCode(uint32_t FileSize)
{
  return FlashGetBackupBootloaderFirmwareCheckCode(FileSize);
}

bool UpdateBackupBootloaderFirmware(void)
{
  return FlashUpdateBootloaderFirmware();
}
